
package com.roc.web.action.diaodan;

import java.sql.Date;
import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

/**
 * @author Feng haitao
 *
 */
public class DiaoDanApplySearchCondition extends BaseSearchCondition {

	private String merNo;
	private String accountno;
	private String etstermId;
	private String termtrace;
	private String etsdate;
	private String period;
	private long[] agentIds; 
	private long agentId;
	private String roleType;
	private String orgCode;
    private String status;
    private String enddate;
    private String etstrace;
    private String diaodantype;
    private String reversal;
	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getOrderPartOfHQL()
	 */
	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub

		return "";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getRowCountHQL()
	 */
	@Override
	protected String getRowCountHQL() {
		StringBuffer sb = new StringBuffer();
		sb
				.append("select count(*) from t_trans_register t where 1=1 ");
		//	    if (Constance.isNotEmpty(merNo)) {
		//	    	sb.append(" and t.merno='"+merNo+"'");
		//	    }
		//	    if (Constance.isNotEmpty(etstermId)) {
		//	    	sb.append(" and t.Etstermid='"+etstermId+"'");
		//	    }
		//	    if (Constance.isNotEmpty(realName)) {
		//	    	sb.append(" and e.MER_NAME like '%"+realName+"%' ");
		//	    }
		//	    if (Constance.isNotEmpty(settFlag)) {
		//	    	sb.append(" and t.SETT_FLAG ='"+settFlag+"'");
		//	    }
		//	    if (Constance.isNotEmpty(minDate)) {
		//	    	sb.append(" and t.TERMDATE>='"+minDate+"'");
		//	    }
		//	    if (Constance.isNotEmpty(maxDate)) {
		//	    	sb.append(" and t.TERMDATE<='"+maxDate+"'");
		//	    }
		//	    if (Constance.isNotEmpty(orgCode)) {
		//	    	sb.append(" and e.BELONG_BRANCH='"+orgCode+"'");
		//	    }

		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getSearchHQL()
	 */
	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub

		return " select t.org_code,t.agent_id,t.merchant_no,  t.merchant_name,  t.trans_date,  t.trans_time,   t.termid, t.termtrace, t.etstrace, t.trans_amt, t.etstrancode, t.respcode, t.status,  t.start_date, t.settle_orderno, t.mcc,  t.period, t.acctno,t.id,t.DDAMOUNT,t.FROZENAMOUNT,t.UNFROZENAMOUNT,t.reversal  from t_trans_register t where 1=1 ";
	}

	/* (non-Javadoc)
	 * @see com.roc.page.BaseSearchCondition#getWhereHQLFieldBeanList()
	 */
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
		
		if (Constance.isNotEmpty(merNo)) {
			filedBeanList.add(new WhereHQLFieldBean("t.merchant_no", merNo
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(status)) {
			filedBeanList.add(new WhereHQLFieldBean("t.status", status
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(etstermId)) {
			filedBeanList.add(new WhereHQLFieldBean("t.termid", etstermId
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(termtrace)) {
			filedBeanList.add(new WhereHQLFieldBean("t.termtrace", termtrace
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(etsdate)) {
			filedBeanList.add(new WhereHQLFieldBean("t.start_date", etsdate
					.trim(), "=", false));
		}
		
		if (Constance.isNotEmpty(orgCode)) {
			filedBeanList.add(new WhereHQLFieldBean("t.orgno", orgCode.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(accountno)) {
			filedBeanList.add(new WhereHQLFieldBean("t.accountno", accountno.trim()
					.trim(), "=", false));
		}
		if (Constance.isNotEmpty(reversal)) {
			filedBeanList.add(new WhereHQLFieldBean("t.reversal", reversal.trim()
					.trim(), "=", false));
		}
		//特约商户
//		if (Constance.isNotEmpty(roleType)) {
//			if(roleType.equals(Constance.MERCHANT_TYPE_MER)){
//				if (Constance.isNotEmpty(merNo)) {
//					filedBeanList.add(new WhereHQLFieldBean("t.merchantno", merNo
//							.trim().trim(), "=", false));
//				}
//			}
//		}
//		if (agentId>0) {
//			filedBeanList.add(new WhereHQLFieldBean("t.agent_id", agentId, "=", false));
//		}
//		if(agentIds!=null&&agentIds.length>0){
//	        	filedBeanList.add(new WhereHQLFieldBean("t.agent_id",agentIds,
//						"IN", false));
//	     }
		return filedBeanList;
	}

	public String getTermtrace() {
		return termtrace;
	}

	public void setTermtrace(String termtrace) {
		this.termtrace = termtrace;
	}

	public String getPeriod() {
		return period;
	}

	public void setPeriod(String period) {
		this.period = period;
	}

	public String getMerNo() {
		return merNo;
	}

	public void setMerNo(String merNo) {
		this.merNo = merNo;
	}

	public String getEtstermId() {
		return etstermId;
	}

	public void setEtstermId(String etstermId) {
		this.etstermId = etstermId;
	}

	

	public String getEtsdate() {
		return etsdate;
	}

	public void setEtsdate(String etsdate) {
		this.etsdate = etsdate;
	}

	public long[] getAgentIds() {
		return agentIds;
	}

	public void setAgentIds(long[] agentIds) {
		this.agentIds = agentIds;
	}

	public long getAgentId() {
		return agentId;
	}

	public void setAgentId(long agentId) {
		this.agentId = agentId;
	}

	public String getRoleType() {
		return roleType;
	}

	public void setRoleType(String roleType) {
		this.roleType = roleType;
	}

	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getEnddate() {
		return enddate;
	}

	public void setEnddate(String enddate) {
		this.enddate = enddate;
	}


	public String getEtstrace() {
		return etstrace;
	}

	public void setEtstrace(String etstrace) {
		this.etstrace = etstrace;
	}

	public String getDiaodantype() {
		return diaodantype;
	}

	public void setDiaodantype(String diaodantype) {
		this.diaodantype = diaodantype;
	}

	public static void main(String[] args) {
		DiaoDanApplySearchCondition s = new DiaoDanApplySearchCondition();
		Object[] ids = new Object[] { "dxpeng", "lisi", "wangwu" };
		//s.setSuperiorId(1l);

		try {

			System.out.println(s.getFullSearchHQL(null));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public String getAccountno() {
		return accountno;
	}

	public void setAccountno(String accountno) {
		this.accountno = accountno;
	}

	public String getReversal() {
		return reversal;
	}

	public void setReversal(String reversal) {
		this.reversal = reversal;
	}
	
}
